package rest;

import java.util.ArrayList;
import java.util.Collection;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import pizza.admin.dao.PizzaDAO;
import pizza.admin.entity.Pizza;

import model.XmlPizza;

/**
 * 
 * @author Radoslav Stoyanov
 *
 */
@Path("/pizza")
public class PizzaRest {
	/**
	 * Method for getting full list of pizzas
	 * @return Collection<XmlPizza>
	 */
	@GET
	@Path("list")
	@Produces(MediaType.APPLICATION_JSON)
	public Collection<XmlPizza> list(){
		Collection<XmlPizza> xmllist = new ArrayList<XmlPizza>();
		PizzaDAO pizzaDAO = new PizzaDAO();
		Collection<Pizza> list = pizzaDAO.getAll();
		
		for(Pizza pizza : list){
			XmlPizza xmlpizza = new XmlPizza(pizza);
			xmllist.add(xmlpizza);
		}
		
		return xmllist;
	}
}
